<template>
	<!-- 添加弹框 -->
	<el-dialog  title="" size='small' visible :show-close="false" closeOnClickModal :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">易耗品进销存管理</div>
			<div class="one" style="text-align: left;">易耗品类</div>
			<div class="jxcgl">
				
			<div class="top" v-if="this.qxbtn.frmrscgrkckyn">
			<router-link :to="{path:'/manage/cgrk',query: {frompage:'4'}}">
			<div class="tp"  style="background:#409EFF;color: white;"><i class="el-icon-edit" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">采购入库</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrskccxckyn">
			<router-link :to="{path:'/manage/kccx',query: {frompage:'4'}}">
			<div class="tp" style="background:#67C23A;color: white;"><i class="el-icon-star-off" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">库存查询</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrslyckckyn">
			<router-link :to="{path:'/manage/lyck',query: {frompage:'4'}}">
			<div class="tp"  style="background:#FA5555;color: white;"><i class="el-icon-document" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">领用出库</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrscgthckyn">
			<router-link :to="{path:'/manage/cgth',query: {frompage:'4'}}">
			<div class="tp"  style="background:#67C23A;color: white;"><i class="el-icon-message" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">采购退货</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrsbsckyn">
			<router-link :to="{path:'/manage/bs',query: {frompage:'4'}}">
			<div class="tp"  style="background:#FA5555;color: white;"><i class="el-icon-date" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">报损</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrspdckyn">
			<router-link :to="{path:'/manage/pd',query: {frompage:'4'}}">
			<div class="tp"  style="background:#8D4FF2;color: white;"><i class="el-icon-document" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">盘点</span></div>
			</router-link>
			</div>
			
			<div class="top" v-if="this.qxbtn.frmrsjckcxckyn" style="width: 18%;">
			<router-link :to="{path:'/manage/jckcx',query: {frompage:'4'}}">
			<div class="tp"  style="background:#EB9E05;color: white;"><i class="el-icon-document" style="margin: 10px 0;font-size:25px;"></i><span style="font-size:16px ;">进出库查询</span></div>
			</router-link>
			</div>
			
			
			</div>
		<PayArticle class="wpfl1" @jcarticle="jcarticleed"  @close="jcarticlecancel" v-if="showarticle"></PayArticle>
		<Kschoose class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
	</el-dialog>
</template>
<script type="text/javascript">
	import Kschoose from '../../manage/kssz/kschoose'
	import PayArticle from './pay-articlejc'
	import qs from 'qs'
	export default {
		components: { Kschoose, PayArticle },
		data() {
			return {
				//查看权限
				qxbtn:{
					//采购入库
					frmrscgrkckyn:false,
					//库存查询
					frmrskccxckyn:false,
					//领用退领
					frmrslytlckyn:false,
					//领用出库
					frmrslyckckyn:false,
					//报损
					frmrsbsckyn:false,
					//报修
					frmrsbxckyn:false,
					//盘点
					frmrspdckyn:false,
					//采购退货
					frmrscgthckyn:false,
					//进出库查询
					frmrsjckcxckyn:false,

				},


				showchoselist: false,
				showarticle: false,
				vfxkcid: '',
				vfxkcidmc: '',
				vmc: '',
				vbtime:'',
				vlsid: '',
				vcid: '',
				vjcid: '',
				vjcidmc: '',
				vlx: '',
				vypks: '',
				xzls:'',
				comboxlist: [],
				dialogTableVisible: true,
				xzlsList: []
			}
		},
		created() {
			//权限
				 var logininfo = JSON.parse(localStorage.logininfo) ;
				 //采购入库
                 this.qxbtn.frmrscgrkckyn = (logininfo.auth.indexOf("frmrscgrkckyn")!=-1);
                 //库存查询
                 this.qxbtn.frmrskccxckyn = (logininfo.auth.indexOf("frmrskccxckyn")!=-1);
                 //领用退领
                 this.qxbtn.frmrslytlckyn = (logininfo.auth.indexOf("frmrslytlckyn")!=-1);
                 //领用出库
                 this.qxbtn.frmrslyckckyn = (logininfo.auth.indexOf("frmrslyckckyn")!=-1);
                  //报损
                 this.qxbtn.frmrsbsckyn = (logininfo.auth.indexOf("frmrsbsckyn")!=-1);
                   //报修
                 this.qxbtn.frmrsbxckyn = (logininfo.auth.indexOf("frmrsbxckyn")!=-1);
                  //盘点
                 this.qxbtn.frmrspdckyn = (logininfo.auth.indexOf("frmrspdckyn")!=-1);
                  //采购退货
                 this.qxbtn.frmrscgthckyn = (logininfo.auth.indexOf("frmrscgthckyn")!=-1);
                 //进出库查询
                 this.qxbtn.frmrsjckcxckyn = (logininfo.auth.indexOf("frmrsjckcxckyn")!=-1);

			this.getcomboxlist();
			this.getxzlsList();
		},
		methods: {
			getxzlsList () {
				var logininfo = JSON.parse(localStorage.logininfo);
					this.axios.get( this.$store.state.api + 'ls/xzxzls', {
							params: {
								yhid: logininfo.id,
								xxid:logininfo.xxid
							}
					})
					.then( res => {
							console.log(res)
							this.xzlsList = res.data.data;
					}).catch( res => {
							console.log(res)
					})
			},
			submit() {
				//检测
				this.$store.state.loading = true;
				if(!this.vfxkcid) {
					this.$message.warning('请选择分校课程');
					this.$store.state.loading = false;
					return;
				}
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xzid:this.xzls,
					fxkcid: this.vfxkcid,
					mc: this.vmc,
					lsid: this.vlsid,
					cid: this.vcid,
					jcid: this.vjcid,
					lx: 'cj',
					ypks: '0',
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					kbrq:time1
				});
				//执行
				this.axios.post(this.$store.state.api + 'bj/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'xhjxcgl', cancel: false });
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				this.vfxkcidmc = josndata.kcmc;
				this.vfxkcid = josndata.fxkcid;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
			    this.vcid = josndata.cid;
			    this.vjcid = josndata.jcid;
			    this.vjcidmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel() {
				this.showchoselist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			cancel() {
				this.$emit('close', { type: 'xhjxcgl', cancel: true })
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist)
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})
			}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
			    top: 10px;
			    font-size: 25px;
				z-index: 10;
				position: absolute;
		}
		.top{
			width: 15%;
		height: 50px;
		// float: left;
		border-radius: 8px;
		margin-right: 15px;
		margin-top: 10px;
		background: white;
		// position: relative;
		box-shadow: 7px 7px 7px #B3B3B3;
		border-radius: 8px;
		}
		.tp {
		width: 100%;
		height:50px;
		// float: left;
		border-radius: 8px;
		background: white;
		// position: relative;
		box-shadow: 7px 7px 7px #B3B3B3;
		border-radius: 8px;
	}
	.jxcgl{
		display: flex;
		justify-content: space-around;
		flex-flow: wrap;
		width: 100%;
		height:100%;
		margin: 0 auto;
		margin-bottom: 20px;
		// float: left;
		/*margin-top: 52px;*/
/*		margin-bottom: 10px;*/
		color: white;
		text-align: center;
		font-size: 16px;
/*		background: white;*/
/*		border-top: 3px solid deepskyblue;*/
	}
	}
</style>
